home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1998 November / Freeware November 1998.img / dist / fw_emacs.idb / usr / freeware / info / emacs-3.z / emacs-3 (.txt)
GNU Info File  |  1998-10-27  |  48KB  |  846 lines

  1. This is Info file ../info/emacs, produced by Makeinfo-1.63 from the
  2. input file emacs.texi.
  3. File: emacs,  Node: Exiting,  Next: Basic,  Prev: Entering Emacs,  Up: Top
  4. Exiting Emacs
  5. =============
  6.    There are two commands for exiting Emacs because there are two kinds
  7. of exiting: "suspending" Emacs and "killing" Emacs.
  8.    "Suspending" means stopping Emacs temporarily and returning control
  9. to its parent process (usually a shell), allowing you to resume editing
  10. later in the same Emacs job, with the same buffers, same kill ring,
  11. same undo history, and so on.  This is the usual way to exit.
  12.    "Killing" Emacs means destroying the Emacs job.  You can run Emacs
  13. again later, but you will get a fresh Emacs; there is no way to resume
  14. the same editing session after it has been killed.
  15. `C-z'
  16.      Suspend Emacs (`suspend-emacs') or iconify a frame
  17.      (`iconify-or-deiconify-frame').
  18. `C-x C-c'
  19.      Kill Emacs (`save-buffers-kill-emacs').
  20.    To suspend Emacs, type `C-z' (`suspend-emacs').  This takes you back
  21. to the shell from which you invoked Emacs.  You can resume Emacs with
  22. the shell command `%emacs' in most common shells.
  23.    On systems that do not support suspending programs, `C-z' starts an
  24. inferior shell that communicates directly with the terminal.  Emacs
  25. waits until you exit the subshell.  (The way to do that is probably
  26. with `C-d' or `exit', but it depends on which shell you use.)  The only
  27. way on these systems to get back to the shell from which Emacs was run
  28. (to log out, for example) is to kill Emacs.
  29.    Suspending also fails if you run Emacs under a shell that doesn't
  30. support suspending programs, even if the system itself does support it.
  31. In such a case, you can set the variable `cannot-suspend' to a
  32. non-`nil' value to force `C-z' to start an inferior shell.  (One might
  33. also describe Emacs's parent shell as "inferior" for failing to support
  34. job control properly, but that is a matter of taste.)
  35.    When Emacs communicates directly with an X server and creates its own
  36. dedicated X windows, `C-z' has a different meaning.  Suspending an
  37. applications that uses its own X windows is not meaningful or useful.
  38. Instead, `C-z' runs the command `iconify-or-deiconify-frame', which
  39. temporarily closes up the selected Emacs frame (*note Frames::.).  The
  40. way to get back to a shell window is with the window manager.
  41.    To kill Emacs, type `C-x C-c' (`save-buffers-kill-emacs').  A
  42. two-character key is used for this to make it harder to type.  This
  43. command first offers to save any modified file-visiting buffers.  If you
  44. do not save them all, it asks for reconfirmation with `yes' before
  45. killing Emacs, since any changes not saved will be lost forever.  Also,
  46. if any subprocesses are still running, `C-x C-c' asks for confirmation
  47. about them, since killing Emacs will kill the subprocesses immediately.
  48.    There is no way to restart an Emacs session once you have killed it.
  49. You can, however, arrange for Emacs to record certain session
  50. information, such as which files are visited, when you kill it, so that
  51. the next time you restart Emacs it will try to visit the same files and
  52. so on.  *Note Saving Emacs Sessions::.
  53.    The operating system usually listens for certain special characters
  54. whose meaning is to kill or suspend the program you are running.  This
  55. operating system feature is turned off while you are in Emacs.  The
  56. meanings of `C-z' and `C-x C-c' as keys in Emacs were inspired by the
  57. use of `C-z' and `C-c' on several operating systems as the characters
  58. for stopping or killing a program, but that is their only relationship
  59. with the operating system.  You can customize these keys to run any
  60. commands of your choice (*note Keymaps::.).
  61. File: emacs,  Node: Basic,  Next: Minibuffer,  Prev: Exiting,  Up: Top
  62. Basic Editing Commands
  63. **********************
  64.    We now give the basics of how to enter text, make corrections, and
  65. save the text in a file.  If this material is new to you, you might
  66. learn it more easily by running the Emacs learn-by-doing tutorial.  To
  67. use the tutorial, run Emacs and type `Control-h t'
  68. (`help-with-tutorial').
  69.    To clear the screen and redisplay, type `C-l' (`recenter').
  70. * Menu:
  71. * Inserting Text::     Inserting text by simply typing it.
  72. * Moving Point::       How to move the cursor to the place where you want to
  73.                  change something.
  74. * Erasing::           Deleting and killing text.
  75. * Undo::               Undoing previous changes.
  76. * Files: Basic Files.  Visiting, creating, and saving files.
  77. * Help: Basic Help.    Asking what a character does.
  78. * Blank Lines::        Commands to make or delete blank lines.
  79. * Continuation Lines:: Lines too wide for the screen.
  80. * Position Info::      What page, line, row, or column is point on?
  81. * Arguments::           Numeric arguments for repeating a command.
  82. File: emacs,  Node: Inserting Text,  Next: Moving Point,  Up: Basic
  83. Inserting Text
  84. ==============
  85.    To insert printing characters into the text you are editing, just
  86. type them.  This inserts the characters you type into the buffer at the
  87. cursor (that is, at "point"; *note Point::.).  The cursor moves
  88. forward, and any text after the cursor moves forward too.  If the text
  89. in the buffer is `FOOBAR', with the cursor before the `B', then if you
  90. type `XX', you get `FOOXXBAR', with the cursor still before the `B'.
  91.    To "delete" text you have just inserted, use DEL.  DEL deletes the
  92. character *before* the cursor (not the one that the cursor is on top of
  93. or under; that is the character AFTER the cursor).  The cursor and all
  94. characters after it move backwards.  Therefore, if you type a printing
  95. character and then type DEL, they cancel out.
  96.    To end a line and start typing a new one, type RET.  This inserts a
  97. newline character in the buffer.  If point is in the middle of a line,
  98. RET splits the line.  Typing DEL when the cursor is at the beginning of
  99. a line deletes the preceding newline, thus joining the line with the
  100. preceding line.
  101.    Emacs can split lines automatically when they become too long, if you
  102. turn on a special minor mode called "Auto Fill" mode.  *Note Filling::,
  103. for how to use Auto Fill mode.
  104.    If you prefer to have text characters replace (overwrite) existing
  105. text rather than shove it to the right, you can enable Overwrite mode,
  106. a minor mode.  *Note Minor Modes::.
  107.    Direct insertion works for printing characters and SPC, but other
  108. characters act as editing commands and do not insert themselves.  If you
  109. need to insert a control character or a character whose code is above
  110. 200 octal, you must "quote" it by typing the character `Control-q'
  111. (`quoted-insert') first.  (This character's name is normally written
  112. `C-q' for short.)  There are two ways to use `C-q':
  113.    * `C-q' followed by any non-graphic character (even `C-g') inserts
  114.      that character.
  115.    * `C-q' followed by three octal digits inserts the character with
  116.      the specified character code.
  117. A numeric argument to `C-q' specifies how many copies of the quoted
  118. character should be inserted (*note Arguments::.).
  119.    Customization information: DEL in most modes runs the command
  120. `delete-backward-char'; RET runs the command `newline', and
  121. self-inserting printing characters run the command `self-insert', which
  122. inserts whatever character was typed to invoke it.  Some major modes
  123. rebind DEL to other commands.
  124. File: emacs,  Node: Moving Point,  Next: Erasing,  Prev: Inserting Text,  Up: Basic
  125. Changing the Location of Point
  126. ==============================
  127.    To do more than insert characters, you have to know how to move point
  128. (*note Point::.).  The simplest way to do this is with arrow keys, or by
  129. clicking the left mouse button where you want to move to.
  130.    There are also control and meta characters for cursor motion.  Some
  131. are equivalent to the arrow keys (these date back to the days before
  132. terminals had arrow keys, and are usable on terminals which don't have
  133. them).  Others do more sophisticated things.
  134. `C-a'
  135.      Move to the beginning of the line (`beginning-of-line').
  136. `C-e'
  137.      Move to the end of the line (`end-of-line').
  138. `C-f'
  139.      Move forward one character (`forward-char').
  140. `C-b'
  141.      Move backward one character (`backward-char').
  142. `M-f'
  143.      Move forward one word (`forward-word').
  144. `M-b'
  145.      Move backward one word (`backward-word').
  146. `C-n'
  147.      Move down one line, vertically (`next-line').  This command
  148.      attempts to keep the horizontal position unchanged, so if you
  149.      start in the middle of one line, you end in the middle of the
  150.      next.  When on the last line of text, `C-n' creates a new line and
  151.      moves onto it.
  152. `C-p'
  153.      Move up one line, vertically (`previous-line').
  154. `M-r'
  155.      Move point to left margin, vertically centered in the window
  156.      (`move-to-window-line').  Text does not move on the screen.
  157.      A numeric argument says which screen line to place point on.  It
  158.      counts screen lines down from the top of the window (zero for the
  159.      top line).  A negative argument counts lines from the bottom (-1
  160.      for the bottom line).
  161. `M-<'
  162.      Move to the top of the buffer (`beginning-of-buffer').  With
  163.      numeric argument N, move to N/10 of the way from the top.  *Note
  164.      Arguments::, for more information on numeric arguments.
  165. `M->'
  166.      Move to the end of the buffer (`end-of-buffer').
  167. `M-x goto-char'
  168.      Read a number N and move point to character number N.  Position 1
  169.      is the beginning of the buffer.
  170. `M-x goto-line'
  171.      Read a number N and move point to line number N.  Line 1 is the
  172.      beginning of the buffer.
  173. `C-x C-n'
  174.      Use the current column of point as the "semipermanent goal column"
  175.      for `C-n' and `C-p' (`set-goal-column').  Henceforth, those
  176.      commands always move to this column in each line moved into, or as
  177.      close as possible given the contents of the line.  This goal
  178.      column remains in effect until canceled.
  179. `C-u C-x C-n'
  180.      Cancel the goal column.  Henceforth, `C-n' and `C-p' once again
  181.      try to stick to a fixed horizontal position, as usual.
  182.    If you set the variable `track-eol' to a non-`nil' value, then `C-n'
  183. and `C-p' when at the end of the starting line move to the end of
  184. another line.  Normally, `track-eol' is `nil'.  *Note Variables::, for
  185. how to set variables such as `track-eol'.
  186.    Normally, `C-n' on the last line of a buffer appends a newline to
  187. it.  If the variable `next-line-add-newlines' is `nil', then `C-n' gets
  188. an error instead (like `C-p' on the first line).
  189. File: emacs,  Node: Erasing,  Next: Undo,  Prev: Moving Point,  Up: Basic
  190. Erasing Text
  191. ============
  192. `DEL'
  193.      Delete the character before point (`delete-backward-char').
  194. `C-d'
  195.      Delete the character after point (`delete-char').
  196. `C-k'
  197.      Kill to the end of the line (`kill-line').
  198. `M-d'
  199.      Kill forward to the end of the next word (`kill-word').
  200. `M-DEL'
  201.      Kill back to the beginning of the previous word
  202.      (`backward-kill-word').
  203.    You already know about the DEL key which deletes the character
  204. before point (that is, before the cursor).  Another key, `Control-d'
  205. (`C-d' for short), deletes the character after point (that is, the
  206. character that the cursor is on).  This shifts the rest of the text on
  207. the line to the left.  If you type `C-d' at the end of a line, it joins
  208. together that line and the next line.
  209.    To erase a larger amount of text, use the `C-k' key, which kills a
  210. line at a time.  If you type `C-k' at the beginning or middle of a
  211. line, it kills all the text up to the end of the line.  If you type
  212. `C-k' at the end of a line, it joins that line and the next line.
  213.    *Note Killing::, for more flexible ways of killing text.
  214. File: emacs,  Node: Undo,  Next: Basic Files,  Prev: Erasing,  Up: Basic
  215. Undoing Changes
  216. ===============
  217.    You can undo all the recent changes in the buffer text, up to a
  218. certain point.  Each buffer records changes individually, and the undo
  219. command always applies to the current buffer.  Usually each editing
  220. command makes a separate entry in the undo records, but some commands
  221. such as `query-replace' make many entries, and very simple commands
  222. such as self-inserting characters are often grouped to make undoing less
  223. tedious.
  224. `C-x u'
  225.      Undo one batch of changes--usually, one command worth (`undo').
  226. `C-_'
  227.      The same.
  228.    The command `C-x u' or `C-_' is how you undo.  The first time you
  229. give this command, it undoes the last change.  Point moves back to
  230. where it was before the command that made the change.
  231.    Consecutive repetitions of `C-_' or `C-x u' undo earlier and earlier
  232. changes, back to the limit of the undo information available.  If all
  233. recorded changes have already been undone, the undo command prints an
  234. error message and does nothing.
  235.    Any command other than an undo command breaks the sequence of undo
  236. commands.  Starting from that moment, the previous undo commands become
  237. ordinary changes that you can undo.  Thus, to redo changes you have
  238. undone, type `C-f' or any other command that will harmlessly break the
  239. sequence of undoing, then type more undo commands.
  240.    If you notice that a buffer has been modified accidentally, the
  241. easiest way to recover is to type `C-_' repeatedly until the stars
  242. disappear from the front of the mode line.  At this time, all the
  243. modifications you made have been canceled.  Whenever an undo command
  244. makes the stars disappear from the mode line, it means that the buffer
  245. contents are the same as they were when the file was last read in or
  246. saved.
  247.    If you do not remember whether you changed the buffer deliberately,
  248. type `C-_' once.  When you see the last change you made undone, you
  249. will see whether it was an intentional change.  If it was an accident,
  250. leave it undone.  If it was deliberate, redo the change as described
  251. above.
  252.    Not all buffers record undo information.  Buffers whose names start
  253. with spaces don't; these buffers are used internally by Emacs and its
  254. extensions to hold text that users don't normally look at or edit.
  255.    You cannot undo mere cursor motion; only changes in the buffer
  256. contents save undo information.  However, some cursor motion commands
  257. set the mark, so if you use these commands from time to time, you can
  258. move back to the neighborhoods you have moved through by popping the
  259. mark ring (*note Mark Ring::.).
  260.    When the undo information for a buffer becomes too large, Emacs
  261. discards the oldest undo information from time to time (during garbage
  262. collection).  You can specify how much undo information to keep by
  263. setting two variables: `undo-limit' and `undo-strong-limit'.  Their
  264. values are expressed in units of bytes of space.
  265.    The variable `undo-limit' sets a soft limit: Emacs keeps undo data
  266. for enough commands to reach this size, and perhaps exceed it, but does
  267. not keep data for any earlier commands beyond that.  Its default value
  268. is 20000.  The variable `undo-strong-limit' sets a stricter limit: the
  269. command which pushes the size past this amount is itself forgotten.
  270. Its default value is 30000.
  271.    Regardless of the values of those variables, the most recent change
  272. is never discarded, so there is no danger that garbage collection
  273. occurring right after an unintentional large change might prevent you
  274. from undoing it.
  275.    The reason the `undo' command has two keys, `C-x u' and `C-_', set
  276. up to run it is that it is worthy of a single-character key, but on
  277. some keyboards it is not obvious how to type `C-_'.  `C-x u' is an
  278. alternative you can type straightforwardly on any terminal.
  279. File: emacs,  Node: Basic Files,  Next: Basic Help,  Prev: Undo,  Up: Basic
  280. Files
  281. =====
  282.    The commands described above are sufficient for creating and altering
  283. text in an Emacs buffer; the more advanced Emacs commands just make
  284. things easier.  But to keep any text permanently you must put it in a
  285. "file".  Files are named units of text which are stored by the
  286. operating system for you to retrieve later by name.  To look at or use
  287. the contents of a file in any way, including editing the file with
  288. Emacs, you must specify the file name.
  289.    Consider a file named `/usr/rms/foo.c'.  In Emacs, to begin editing
  290. this file, type
  291.      C-x C-f /usr/rms/foo.c RET
  292. Here the file name is given as an "argument" to the command `C-x C-f'
  293. (`find-file').  That command uses the "minibuffer" to read the
  294. argument, and you type RET to terminate the argument (*note
  295. Minibuffer::.).
  296.    Emacs obeys the command by "visiting" the file: creating a buffer,
  297. copying the contents of the file into the buffer, and then displaying
  298. the buffer for you to edit.  If you alter the text, you can "save" the
  299. new text in the file by typing `C-x C-s' (`save-buffer').  This makes
  300. the changes permanent by copying the altered buffer contents back into
  301. the file `/usr/rms/foo.c'.  Until you save, the changes exist only
  302. inside Emacs, and the file `foo.c' is unaltered.
  303.    To create a file, just visit the file with `C-x C-f' as if it
  304. already existed.  This creates an empty buffer in which you can insert
  305. the text you want to put in the file.  The file is actually created when
  306. you save this buffer with `C-x C-s'.
  307.    Of course, there is a lot more to learn about using files.  *Note
  308. Files::.
  309. File: emacs,  Node: Basic Help,  Next: Blank Lines,  Prev: Basic Files,  Up: Basic
  310.    If you forget what a key does, you can find out with the Help
  311. character, which is `C-h' (or F1, which is an alias for `C-h').  Type
  312. `C-h k' followed by the key you want to know about; for example, `C-h k
  313. C-n' tells you all about what `C-n' does.  `C-h' is a prefix key; `C-h
  314. k' is just one of its subcommands (the command `describe-key').  The
  315. other subcommands of `C-h' provide different kinds of help.  Type `C-h'
  316. twice to get a description of all the help facilities.  *Note Help::.
  317. File: emacs,  Node: Blank Lines,  Next: Continuation Lines,  Prev: Basic Help,  Up: Basic
  318. Blank Lines
  319. ===========
  320.    Here are special commands and techniques for putting in and taking
  321. out blank lines.
  322. `C-o'
  323.      Insert one or more blank lines after the cursor (`open-line').
  324. `C-x C-o'
  325.      Delete all but one of many consecutive blank lines
  326.      (`delete-blank-lines').
  327.    When you want to insert a new line of text before an existing line,
  328. you can do it by typing the new line of text, followed by RET.
  329. However, it may be easier to see what you are doing if you first make a
  330. blank line and then insert the desired text into it.  This is easy to do
  331. using the key `C-o' (`open-line'), which inserts a newline after point
  332. but leaves point in front of the newline.  After `C-o', type the text
  333. for the new line.  `C-o F O O' has the same effect as `F O O RET',
  334. except for the final location of point.
  335.    You can make several blank lines by typing `C-o' several times, or
  336. by giving it a numeric argument to tell it how many blank lines to make.
  337. *Note Arguments::, for how.  If you have a fill prefix, then `C-o'
  338. command inserts the fill prefix on the new line, when you use it at the
  339. beginning of a line.  *Note Fill Prefix::.
  340.    The easy way to get rid of extra blank lines is with the command
  341. `C-x C-o' (`delete-blank-lines').  `C-x C-o' in a run of several blank
  342. lines deletes all but one of them.  `C-x C-o' on a solitary blank line
  343. deletes that blank line.  When point is on a nonblank line, `C-x C-o'
  344. deletes any blank lines following that nonblank line.
  345. File: emacs,  Node: Continuation Lines,  Next: Position Info,  Prev: Blank Lines,  Up: Basic
  346. Continuation Lines
  347. ==================
  348.    If you add too many characters to one line without breaking it with
  349. RET, the line will grow to occupy two (or more) lines on the screen,
  350. with a `\' at the extreme right margin of all but the last of them.
  351. The `\' says that the following screen line is not really a distinct
  352. line in the text, but just the "continuation" of a line too long to fit
  353. the screen.  Continuation is also called "line wrapping".
  354.    Sometimes it is nice to have Emacs insert newlines automatically when
  355. a line gets too long.  Continuation on the screen does not do that.  Use
  356. Auto Fill mode (*note Filling::.) if that's what you want.
  357.    As an alternative to continuation, Emacs can display long lines by
  358. "truncation".  This means that all the characters that do not fit in
  359. the width of the screen or window do not appear at all.  They remain in
  360. the buffer, temporarily invisible.  `$' is used in the last column
  361. instead of `\' to inform you that truncation is in effect.
  362.    Truncation instead of continuation happens whenever horizontal
  363. scrolling is in use, and optionally in all side-by-side windows (*note
  364. Windows::.).  You can enable truncation for a particular buffer by
  365. setting the variable `truncate-lines' to non-`nil' in that buffer.
  366. (*Note Variables::.)  Altering the value of `truncate-lines' makes it
  367. local to the current buffer; until that time, the default value is in
  368. effect.  The default is initially `nil'.  *Note Locals::.
  369.    *Note Display Vars::, for additional variables that affect how text
  370. is displayed.
  371. File: emacs,  Node: Position Info,  Next: Arguments,  Prev: Continuation Lines,  Up: Basic
  372. Cursor Position Information
  373. ===========================
  374.    Here are commands to get information about the size and position of
  375. parts of the buffer, and to count lines.
  376. `M-x what-page'
  377.      Print page number of point, and line number within page.
  378. `M-x what-line'
  379.      Print line number of point in the buffer.
  380. `M-x line-number-mode'
  381.      Toggle automatic display of current line number.
  382. `M-='
  383.      Print number of lines in the current region (`count-lines-region').
  384.      *Note Mark::, for information about the region.
  385. `C-x ='
  386.      Print character code of character after point, character position
  387.      of point, and column of point (`what-cursor-position').
  388.    There are two commands for working with line numbers.  `M-x
  389. what-line' computes the current line number and displays it in the echo
  390. area.  To go to a given line by number, use `M-x goto-line'; it prompts
  391. you for the number.  These line numbers count from one at the beginning
  392. of the buffer.
  393.    You can also see the current line number in the mode line; *Note
  394. Mode Line::.  If you narrow the buffer, then the line number in the
  395. mode line is relative to the accessible portion (*note Narrowing::.).
  396. By contrast, `what-line' shows both the line number relative to the
  397. narrowed region and the line number relative to the whole buffer.
  398.    By contrast, `M-x what-page' counts pages from the beginning of the
  399. file, and counts lines within the page, printing both numbers.  *Note
  400. Pages::.
  401.    While on this subject, we might as well mention `M-='
  402. (`count-lines-region'), which prints the number of lines in the region
  403. (*note Mark::.).  *Note Pages::, for the command `C-x l' which counts
  404. the lines in the current page.
  405.    The command `C-x =' (`what-cursor-position') can be used to find out
  406. the column that the cursor is in, and other miscellaneous information
  407. about point.  It prints a line in the echo area that looks like this:
  408.      Char: c (0143, 99, 0x63)  point=21044 of 26883(78%)  column 53
  409. (In fact, this is the output produced when point is before the `column'
  410. in the example.)
  411.    The two values after `Char:' describe the character that follows
  412. point, first by showing it and second by giving its octal character
  413. code.
  414.    `point=' is followed by the position of point expressed as a
  415. character count.  The front of the buffer counts as position 1, one
  416. character later as 2, and so on.  The next, larger number is the total
  417. number of characters in the buffer.  Afterward in parentheses comes the
  418. position expressed as a percentage of the total size.
  419.    `column' is followed by the horizontal position of point, in columns
  420. from the left edge of the window.
  421.    If the buffer has been narrowed, making some of the text at the
  422. beginning and the end temporarily inaccessible, `C-x =' prints
  423. additional text describing the currently accessible range.  For
  424. example, it might display this:
  425.      Char: C (0103, 67, 0x43)  point=22015 of 26889(82%) <21660 - 22099>  column 0
  426. where the two extra numbers give the smallest and largest character
  427. position that point is allowed to assume.  The characters between those
  428. two positions are the accessible ones.  *Note Narrowing::.
  429.    If point is at the end of the buffer (or the end of the accessible
  430. part), `C-x =' omits any description of the character after point.  The
  431. output might look like this:
  432.      point=26957 of 26956(100%)  column 0
  433. File: emacs,  Node: Arguments,  Prev: Position Info,  Up: Basic
  434. Numeric Arguments
  435. =================
  436.    In mathematics and computer usage, the word "argument" means "data
  437. provided to a function or operation."  You can give any Emacs command a
  438. "numeric argument" (also called a "prefix argument").  Some commands
  439. interpret the argument as a repetition count.  For example, `C-f' with
  440. an argument of ten moves forward ten characters instead of one.  With
  441. these commands, no argument is equivalent to an argument of one.
  442. Negative arguments tell most such commands to move or act in the
  443. opposite direction.
  444.    If your terminal keyboard has a META key, the easiest way to specify
  445. a numeric argument is to type digits and/or a minus sign while holding
  446. down the the META key.  For example,
  447.      M-5 C-n
  448. would move down five lines.  The characters `Meta-1', `Meta-2', and so
  449. on, as well as `Meta--', do this because they are keys bound to
  450. commands (`digit-argument' and `negative-argument') that are defined to
  451. contribute to an argument for the next command.  Digits and `-'
  452. modified with Control, or Control and Meta, also specify numeric
  453. arguments.
  454.    Another way of specifying an argument is to use the `C-u'
  455. (`universal-argument') command followed by the digits of the argument.
  456. With `C-u', you can type the argument digits without holding down
  457. modifier keys; `C-u' works on all terminals.  To type a negative
  458. argument, type a minus sign after `C-u'.  Just a minus sign without
  459. digits normally means -1.
  460.    `C-u' followed by a character which is neither a digit nor a minus
  461. sign has the special meaning of "multiply by four".  It multiplies the
  462. argument for the next command by four.  `C-u' twice multiplies it by
  463. sixteen.  Thus, `C-u C-u C-f' moves forward sixteen characters.  This
  464. is a good way to move forward "fast", since it moves about 1/5 of a line
  465. in the usual size screen.  Other useful combinations are `C-u C-n',
  466. `C-u C-u C-n' (move down a good fraction of a screen), `C-u C-u C-o'
  467. (make "a lot" of blank lines), and `C-u C-k' (kill four lines).
  468.    Some commands care only about whether there is an argument, and not
  469. about its value.  For example, the command `M-q' (`fill-paragraph') with
  470. no argument fills text; with an argument, it justifies the text as well.
  471. (*Note Filling::, for more information on `M-q'.)  Plain `C-u' is a
  472. handy way of providing an argument for such commands.
  473.    Some commands use the value of the argument as a repeat count, but do
  474. something peculiar when there is no argument.  For example, the command
  475. `C-k' (`kill-line') with argument N kills N lines, including their
  476. terminating newlines.  But `C-k' with no argument is special: it kills
  477. the text up to the next newline, or, if point is right at the end of
  478. the line, it kills the newline itself.  Thus, two `C-k' commands with
  479. no arguments can kill a nonblank line, just like `C-k' with an argument
  480. of one.  (*Note Killing::, for more information on `C-k'.)
  481.    A few commands treat a plain `C-u' differently from an ordinary
  482. argument.  A few others may treat an argument of just a minus sign
  483. differently from an argument of -1.  These unusual cases are described
  484. when they come up; they are always for reasons of convenience of use of
  485. the individual command.
  486.    You can use a numeric argument to insert multiple copies of a
  487. character.  This is straightforward unless the character is a digit; for
  488. example, `C-u 6 4 a' inserts 64 copies of the character `a'.  But this
  489. does not work for inserting digits; `C-u 6 4 1' specifies an argument
  490. of 641, rather than inserting anything.  To separate the digit to
  491. insert from the argument, type another `C-u'; for example, `C-u 6 4 C-u
  492. 1' does insert 64 copies of the character `1'.
  493.    We use the term "prefix argument" as well as "numeric argument" to
  494. emphasize that you type the argument before the command, and to
  495. distinguish these arguments from minibuffer arguments that come after
  496. the command.
  497. File: emacs,  Node: Minibuffer,  Next: M-x,  Prev: Basic,  Up: Top
  498. The Minibuffer
  499. **************
  500.    The "minibuffer" is the facility used by Emacs commands to read
  501. arguments more complicated than a single number.  Minibuffer arguments
  502. can be file names, buffer names, Lisp function names, Emacs command
  503. names, Lisp expressions, and many other things, depending on the command
  504. reading the argument.  You can use the usual Emacs editing commands in
  505. the minibuffer to edit the argument text.
  506.    When the minibuffer is in use, it appears in the echo area, and the
  507. terminal's cursor moves there.  The beginning of the minibuffer line
  508. displays a "prompt" which says what kind of input you should supply and
  509. how it will be used.  Often this prompt is derived from the name of the
  510. command that the argument is for.  The prompt normally ends with a
  511. colon.
  512.    Sometimes a "default argument" appears in parentheses after the
  513. colon; it too is part of the prompt.  The default will be used as the
  514. argument value if you enter an empty argument (e.g., just type RET).
  515. For example, commands that read buffer names always show a default,
  516. which is the name of the buffer that will be used if you type just RET.
  517.    The simplest way to enter a minibuffer argument is to type the text
  518. you want, terminated by RET which exits the minibuffer.  You can cancel
  519. the command that wants the argument, and get out of the minibuffer, by
  520. typing `C-g'.
  521.    Since the minibuffer uses the screen space of the echo area, it can
  522. conflict with other ways Emacs customarily uses the echo area.  Here is
  523. how Emacs handles such conflicts:
  524.    * If a command gets an error while you are in the minibuffer, this
  525.      does not cancel the minibuffer.  However, the echo area is needed
  526.      for the error message and therefore the minibuffer itself is
  527.      hidden for a while.  It comes back after a few seconds, or as soon
  528.      as you type anything.
  529.    * If in the minibuffer you use a command whose purpose is to print a
  530.      message in the echo area, such as `C-x =', the message is printed
  531.      normally, and the minibuffer is hidden for a while.  It comes back
  532.      after a few seconds, or as soon as you type anything.
  533.    * Echoing of keystrokes does not take place while the minibuffer is
  534.      in use.
  535. * Menu:
  536. * File: Minibuffer File.  Entering file names with the minibuffer.
  537. * Edit: Minibuffer Edit.  How to edit in the minibuffer.
  538. * Completion::          An abbreviation facility for minibuffer input.
  539. * Minibuffer History::    Reusing recent minibuffer arguments.
  540. * Repetition::          Re-executing commands that used the minibuffer.
  541. File: emacs,  Node: Minibuffer File,  Next: Minibuffer Edit,  Up: Minibuffer
  542. Minibuffers for File Names
  543. ==========================
  544.    Sometimes the minibuffer starts out with text in it.  For example,
  545. when you are supposed to give a file name, the minibuffer starts out
  546. containing the "default directory", which ends with a slash.  This is
  547. to inform you which directory the file will be found in if you do not
  548. specify a directory.
  549.    For example, the minibuffer might start out with these contents:
  550.      Find File: /u2/emacs/src/
  551. where `Find File: ' is the prompt.  Typing `buffer.c' specifies the
  552. file `/u2/emacs/src/buffer.c'.  To find files in nearby directories,
  553. use `..'; thus, if you type `../lisp/simple.el', you will get the file
  554. named `/u2/emacs/lisp/simple.el'.  Alternatively, you can kill with
  555. `M-DEL' the directory names you don't want (*note Words::.).
  556.    If you don't want any of the default, you can kill it with `C-a
  557. C-k'.  But you don't need to kill the default; you can simply ignore it.
  558. Insert an absolute file name, one starting with a slash or a tilde,
  559. after the default directory.  For example, to specify the file
  560. `/etc/termcap', just insert that name, giving these minibuffer contents:
  561.      Find File: /u2/emacs/src//etc/termcap
  562. Two slashes in a row are not normally meaningful in a file name, but
  563. they are allowed in GNU Emacs.  They mean, "ignore everything before
  564. the second slash in the pair."  Thus, `/u2/emacs/src/' is ignored in
  565. the example above, and you get the file `/etc/termcap'.
  566.    If you set `insert-default-directory' to `nil', the default
  567. directory is not inserted in the minibuffer.  This way, the minibuffer
  568. starts out empty.  But the name you type, if relative, is still
  569. interpreted with respect to the same default directory.
  570. File: emacs,  Node: Minibuffer Edit,  Next: Completion,  Prev: Minibuffer File,  Up: Minibuffer
  571. Editing in the Minibuffer
  572. =========================
  573.    The minibuffer is an Emacs buffer (albeit a peculiar one), and the
  574. usual Emacs commands are available for editing the text of an argument
  575. you are entering.
  576.    Since RET in the minibuffer is defined to exit the minibuffer, you
  577. can't use it to insert a newline in the minibuffer.  To do that, type
  578. `C-o' or `C-q LFD'.  (Recall that a newline is really the LFD
  579. character.)
  580.    The minibuffer has its own window which always has space on the
  581. screen but acts as if it were not there when the minibuffer is not in
  582. use.  When the minibuffer is in use, its window is just like the
  583. others; you can switch to another window with `C-x o', edit text in
  584. other windows and perhaps even visit more files, before returning to
  585. the minibuffer to submit the argument.  You can kill text in another
  586. window, return to the minibuffer window, and then yank the text to use
  587. it in the argument.  *Note Windows::.
  588.    There are some restrictions on the use of the minibuffer window,
  589. however.  You cannot switch buffers in it--the minibuffer and its
  590. window are permanently attached.  Also, you cannot split or kill the
  591. minibuffer window.  But you can make it taller in the normal fashion
  592. with `C-x ^'.  If you enable Resize-Minibuffer mode, then the
  593. minibuffer window expands vertically as necessary to hold the text that
  594. you put in the minibuffer.  Use `M-x resize-minibuffer-mode' to enable
  595. or disable this minor mode (*note Minor Modes::.).
  596.    If while in the minibuffer you issue a command that displays help
  597. text of any sort in another window, you can use the `C-M-v' command
  598. while in the minibuffer to scroll the help text.  This lasts until you
  599. exit the minibuffer.  This feature is especially useful if a completing
  600. minibuffer gives you a list of possible completions.  *Note Other
  601. Window::.
  602.    Emacs normally disallows most commands that use the minibuffer while
  603. the minibuffer is selected.  This rule is to prevent recursive
  604. minibuffers from confusing novice users.  If you want to be able to use
  605. such commands in the minibuffer, set the variable
  606. `enable-recursive-minibuffers' to a non-`nil' value.
  607. File: emacs,  Node: Completion,  Next: Minibuffer History,  Prev: Minibuffer Edit,  Up: Minibuffer
  608. Completion
  609. ==========
  610.    For certain kinds of arguments, you can use "completion" to enter
  611. the argument value.  Completion means that you type part of the
  612. argument, then Emacs visibly fills in the rest, or as much as can be
  613. determined from the part you have typed.
  614.    When completion is available, certain keys--TAB, RET, and SPC--are
  615. rebound to complete the text present in the minibuffer into a longer
  616. string that it stands for, by matching it against a set of "completion
  617. alternatives" provided by the command reading the argument.  `?' is
  618. defined to display a list of possible completions of what you have
  619. inserted.
  620.    For example, when `M-x' uses the minibuffer to read the name of a
  621. command, it provides a list of all available Emacs command names to
  622. complete against.  The completion keys match the text in the minibuffer
  623. against all the command names, find any additional name characters
  624. implied by the ones already present in the minibuffer, and add those
  625. characters to the ones you have given.  This is what makes it possible
  626. to type `M-x ins SPC b RET' instead of `M-x insert-buffer RET' (for
  627. example).
  628.    Case is normally significant in completion, because it is significant
  629. in most of the names that you can complete (buffer names, file names and
  630. command names).  Thus, `fo' does not complete to `Foo'.  Completion
  631. does ignore case distinctions for certain arguments in which case does
  632. not matter.
  633. * Menu:
  634. * Example: Completion Example.
  635. * Commands: Completion Commands.
  636. * Strict Completion::
  637. * Options: Completion Options.
  638. File: emacs,  Node: Completion Example,  Next: Completion Commands,  Up: Completion
  639. Completion Example
  640. ------------------
  641.    A concrete example may help here.  If you type `M-x au TAB', the TAB
  642. looks for alternatives (in this case, command names) that start with
  643. `au'.  There are only two: `auto-fill-mode' and `auto-save-mode'.
  644. These are the same as far as `auto-', so the `au' in the minibuffer
  645. changes to `auto-'.
  646.    If you type TAB again immediately, there are multiple possibilities
  647. for the very next character--it could be `s' or `f'--so no more
  648. characters are added; instead, TAB displays a list of all possible
  649. completions in another window.
  650.    If you go on to type `f TAB', this TAB sees `auto-f'.  The only
  651. command name starting this way is `auto-fill-mode', so completion fills
  652. in the rest of that.  You now have `auto-fill-mode' in the minibuffer
  653. after typing just `au TAB f TAB'.  Note that TAB has this effect
  654. because in the minibuffer it is bound to the command
  655. `minibuffer-complete' when completion is available.
  656. File: emacs,  Node: Completion Commands,  Next: Strict Completion,  Prev: Completion Example,  Up: Completion
  657. Completion Commands
  658. -------------------
  659.    Here is a list of the completion commands defined in the minibuffer
  660. when completion is available.
  661. `TAB'
  662.      Complete the text in the minibuffer as much as possible
  663.      (`minibuffer-complete').
  664. `SPC'
  665.      Complete the minibuffer text, but don't go beyond one word
  666.      (`minibuffer-complete-word').
  667. `RET'
  668.      Submit the text in the minibuffer as the argument, possibly
  669.      completing first as described below
  670.      (`minibuffer-complete-and-exit').
  671.      Print a list of all possible completions of the text in the
  672.      minibuffer (`minibuffer-list-completions').
  673.    SPC completes much like TAB, but never goes beyond the next hyphen
  674. or space.  If you have `auto-f' in the minibuffer and type SPC, it
  675. finds that the completion is `auto-fill-mode', but it stops completing
  676. after `fill-'.  This gives `auto-fill-'.  Another SPC at this point
  677. completes all the way to `auto-fill-mode'.  SPC in the minibuffer when
  678. completion is available runs the command `minibuffer-complete-word'.
  679.    Here are some commands you can use to choose a completion from a
  680. window that displays a list of completions:
  681. `Mouse-2'
  682.      Clicking mouse button 2 on a completion in the list of possible
  683.      completions chooses that completion (`mouse-choose-completion').
  684.      You normally use this command while point is in the minibuffer;
  685.      but you must click in the list of completions, not in the
  686.      minibuffer itself.
  687. `PRIOR'
  688. `M-v'
  689.      Typing PRIOR or PAGE-UP, or `M-v', while in the minibuffer,
  690.      selects the window showing the completion list buffer
  691.      (`switch-to-completions').  This paves the way for using the
  692.      commands below.  (Selecting that window in the usual ways has the
  693.      same effect, but this way is more convenient.)
  694. `RET'
  695.      Typing RET *in the completion list buffer* chooses the completion
  696.      that point is in or next to (`choose-completion').  To use this
  697.      command, you must first switch windows to the window that shows
  698.      the list of completions.
  699. `RIGHT'
  700.      Typing the right-arrow key RIGHT *in the completion list buffer*
  701.      moves point to the following completion (`next-completion').
  702. `LEFT'
  703.      Typing the left-arrow key LEFT *in the completion list buffer*
  704.      moves point toward the beginning of the buffer, to the previous
  705.      completion (`previous-completion').
  706. File: emacs,  Node: Strict Completion,  Next: Completion Options,  Prev: Completion Commands,  Up: Completion
  707. Strict Completion
  708. -----------------
  709.    There are three different ways that RET can work in completing
  710. minibuffers, depending on how the argument will be used.
  711.    * "Strict" completion is used when it is meaningless to give any
  712.      argument except one of the known alternatives.  For example, when
  713.      `C-x k' reads the name of a buffer to kill, it is meaningless to
  714.      give anything but the name of an existing buffer.  In strict
  715.      completion, RET refuses to exit if the text in the minibuffer does
  716.      not complete to an exact match.
  717.    * "Cautious" completion is similar to strict completion, except that
  718.      RET exits only if the text was an exact match already, not needing
  719.      completion.  If the text is not an exact match, RET does not exit,
  720.      but it does complete the text.  If it completes to an exact match,
  721.      a second RET will exit.
  722.      Cautious completion is used for reading file names for files that
  723.      must already exist.
  724.    * "Permissive" completion is used when any string whatever is
  725.      meaningful, and the list of completion alternatives is just a
  726.      guide.  For example, when `C-x C-f' reads the name of a file to
  727.      visit, any file name is allowed, in case you want to create a
  728.      file.  In permissive completion, RET takes the text in the
  729.      minibuffer exactly as given, without completing it.
  730.    The completion commands display a list of all possible completions in
  731. a window whenever there is more than one possibility for the very next
  732. character.  Also, typing `?' explicitly requests such a list.  If the
  733. list of completions is long, you can scroll it with `C-M-v' (*note
  734. Other Window::.).
  735. File: emacs,  Node: Completion Options,  Prev: Strict Completion,  Up: Completion
  736. Completion Options
  737. ------------------
  738.    When completion is done on file names, certain file names are usually
  739. ignored.  The variable `completion-ignored-extensions' contains a list
  740. of strings; a file whose name ends in any of those strings is ignored
  741. as a possible completion.  The standard value of this variable has
  742. several elements including `".o"', `".elc"', `".dvi"' and `"~"'.  The
  743. effect is that, for example, `foo' can complete to `foo.c' even though
  744. `foo.o' exists as well.  However, if *all* the possible completions end
  745. in "ignored" strings, then they are not ignored.  Ignored extensions do
  746. not apply to lists of completions--those always mention all possible
  747. completions.
  748.    Normally, a completion command that finds the next character is
  749. undetermined automatically displays a list of all possible completions.
  750. If the variable `completion-auto-help' is set to `nil', this does not
  751. happen, and you must type `?' to display the possible completions.
  752.    The `complete' library implements a more powerful kind of completion
  753. that can complete multiple words at a time.  For example, it can
  754. complete the command name abbreviation `p-b' into `print-buffer',
  755. because no other command starts with two words whose initials are `p'
  756. and `b'.  To use this library, put `(load "complete")' in your
  757. `~/.emacs' file (*note Init File::.).
  758.    Icomplete mode presents a constantly-updated display that tells you
  759. what completions are available for the text you've entered so far.  The
  760. command to enable or disable this minor mode is `M-x icomplete-mode'.
  761. File: emacs,  Node: Minibuffer History,  Next: Repetition,  Prev: Completion,  Up: Minibuffer
  762. Minibuffer History
  763. ==================
  764.    Every argument that you enter with the minibuffer is saved on a
  765. "minibuffer history list" so that you can use it again later in another
  766. argument.  Special commands load the text of an earlier argument in the
  767. minibuffer.  They discard the old minibuffer contents, so you can think
  768. of them as moving through the history of previous arguments.
  769. `M-p'
  770.      Move to the next earlier argument string saved in the minibuffer
  771.      history (`previous-history-element').
  772. `M-n'
  773.      Move to the next later argument string saved in the minibuffer
  774.      history (`next-history-element').
  775. `M-r REGEXP RET'
  776.      Move to an earlier saved argument in the minibuffer history that
  777.      has a match for REGEXP (`previous-matching-history-element').
  778. `M-s REGEXP RET'
  779.      Move to a later saved argument in the minibuffer history that has a
  780.      match for REGEXP (`next-matching-history-element').
  781.    The simplest way to reuse the saved arguments in the history list is
  782. to move through the history list one element at a time.  While in the
  783. minibuffer, type `M-p' (`previous-history-element') to "move to" the
  784. next earlier minibuffer input, and use `M-n' (`next-history-element')
  785. to "move to" the next later input.
  786.    The previous input that you fetch from the history entirely replaces
  787. the contents of the minibuffer.  To use it as the argument, exit the
  788. minibuffer as usual with RET.  You can also edit the text before you
  789. reuse it; this does not change the history element that you "moved" to,
  790. but your new argument does go at the end of the history list in its own
  791. right.
  792.    There are also commands to search forward or backward through the
  793. history.  As of this writing, they search for history elements that
  794. match a regular expression that you specify with the minibuffer.  `M-r'
  795. (`previous-matching-history-element') searches older elements in the
  796. history, while `M-s' (`next-matching-history-element') searches newer
  797. elements.  By special dispensation, these commands can use the
  798. minibuffer to read their arguments even though you are already in the
  799. minibuffer when you issue them.
  800.    All uses of the minibuffer record your input on a history list, but
  801. there are separate history lists for different kinds of arguments.  For
  802. example, there is a list for file names, used by all the commands that
  803. read file names.  There is a list for arguments of commands like
  804. `query-replace'.  There are several very specific history lists,
  805. including one for command names read by M-x and one for compilation
  806. commands read by `compile'.  Finally, there is one "miscellaneous"
  807. history list that most minibuffer arguments use.
  808. File: emacs,  Node: Repetition,  Prev: Minibuffer History,  Up: Minibuffer
  809. Repeating Minibuffer Commands
  810. =============================
  811.    Every command that uses the minibuffer at least once is recorded on a
  812. special history list, together with the values of its arguments, so that
  813. you can repeat the entire command.  In particular, every use of `M-x'
  814. is recorded there, since `M-x' uses the minibuffer to read the command
  815. name.
  816. `C-x ESC ESC'
  817.      Re-execute a recent minibuffer command (`repeat-complex-command').
  818. `M-x list-command-history'
  819.      Display the entire command history, showing all the commands `C-x
  820.      ESC ESC' can repeat, most recent first.
  821.    `C-x ESC ESC' is used to re-execute a recent minibuffer-using
  822. command.  With no argument, it repeats the last such command.  A
  823. numeric argument specifies which command to repeat; one means the last
  824. one, and larger numbers specify earlier ones.
  825.    `C-x ESC ESC' works by turning the previous command into a Lisp
  826. expression and then entering a minibuffer initialized with the text for
  827. that expression.  If you type just RET, the command is repeated as
  828. before.  You can also change the command by editing the Lisp
  829. expression.  Whatever expression you finally submit is what will be
  830. executed.  The repeated command is added to the front of the command
  831. history unless it is identical to the most recently executed command
  832. already there.
  833.    Even if you don't understand Lisp syntax, it will probably be obvious
  834. which command is displayed for repetition.  If you do not change the
  835. text, it will repeat exactly as before.
  836.    Once inside the minibuffer for `C-x ESC ESC', you can use the
  837. minibuffer history commands (`M-p', `M-n', `M-r', `M-s'; *note
  838. Minibuffer History::.) to move through the history list of saved entire
  839. commands.  After finding the desired previous command, you can edit its
  840. expression as usual and then resubmit it by typing RET as usual.
  841.    The list of previous minibuffer-using commands is stored as a Lisp
  842. list in the variable `command-history'.  Each element is a Lisp
  843. expression which describes one command and its arguments.  Lisp programs
  844. can reexecute a command by calling `eval' with the `command-history'
  845. element.
  846.